using GolSig.Library;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;

namespace Test.GolSig.Library.BoardSpecs
{
    [TestClass()]
    public class WhenCallingGetCurrentCellInfo
    {
       
        [TestMethod()]
        public void GivenValidPosition_thenShouldGiveCelleInfoForRequestedPosition()
        {
            BoardSize boardSize = new BoardSize(3, 3);
            Board target = new Board(boardSize);
            Position position = new Position(0, 0);

            CellInfo newCellInfo = new CellInfo(position, true);
            target.Initialize(new List<CellInfo> { newCellInfo });

            CellInfo expected = newCellInfo;
            CellInfo actual;
            actual = target.GetCurrentCellInfo(position);
            Assert.IsTrue(expected.Equals( actual));
            
        }




        [TestMethod(), ExpectedException(typeof(System.ArgumentOutOfRangeException))]
        public void GivenInvalidPosition_thenShouldRaiseException()
        {
            BoardSize boardSize = new BoardSize(3, 3);
            Board target = new Board(boardSize);
            Position position = new Position(0, 0);

            CellInfo newCellInfo = new CellInfo(position, true);
            target.Initialize(new List<CellInfo> { newCellInfo });

            CellInfo expected = newCellInfo;
            CellInfo actual;
            actual = target.GetCurrentCellInfo(new Position(4,4));
            Assert.Fail("expected exception");

        }



        [TestMethod(), ExpectedException(typeof(System.ArgumentNullException))]
        public void GivenNullPosition_thenShouldRaiseException()
        {
            BoardSize boardSize = new BoardSize(3, 3);
            Board target = new Board(boardSize);
            Position position = new Position(0, 0);

            CellInfo newCellInfo = new CellInfo(position, true);
            target.Initialize(new List<CellInfo> { newCellInfo });

            CellInfo expected = newCellInfo;
            CellInfo actual;
            actual = target.GetCurrentCellInfo(null);
            Assert.Fail("expected exception");

        }

    }
}
